#include <stdio.h>
#include <string.h>

#define MAXN 100080
int generator[MAXN];

int main() {
  int i, m;
  memset(generator, 0, sizeof(generator));
  for (i = 1; i <= 100000; i++) {
    m = get_sum(i);    
    if (generator[m] == 0 || i < generator[m]) {
      generator[m] = i;
    }
  }
  
  int t, n;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    printf("%d\n", generator[n]);
  }
  
  return 0;
}

int get_sum(int g) {
  int m = g, n = 0;  
  while (m > 0) {
    n += (m % 10);
    m /= 10;
  }
  
  return g + n;
}
